<text>-- !Grinder Tool 窶「 Loads at startupfunction undoubleHTML suffixes put empty into trimmedsuffixes put return& suffixes &return into suffixes repeat with x= 2 to (the number of lines in suffixes) get line x of suffixes if it = ".html" and (return&".htm" &return) is in suffixes then next repeat put it &return after trimmedsuffixes end repeat delete last char of trimmedsuffixes return trimmedsuffixesend undoubleHTMLon unregisterApp go homie() put empty into cd fld "startingdate" put empty into cd fld "username" put empty into cd fld "status" put empty into cd fld "serial number"end unregisterappon mouseWithin get word 1 to 2 of the target && number of the target FullBalloons "IsShowing" if not the Result and it 竕 the selectedField then send mouseEnter to the targetend mouseWithinon openField FullBalloons "remove" pass openfieldend openFieldon reghelp if word 1 of the value of the target is "unregistered" then get "This tool is not registered and will expire unless you purchase a serial number from"&return&ツャ "http://www.matterform.com/" else get "Thank you for registering this software. Feel free to share it with others since it will revert to Demo mode when it is copied to another Macintosh." end if helper itend reghelpon help if there is a bg btn "help" then set the hilite of bg btn help to true wait 5 set the hilite of bg btn help to false end if fullhelpend helpon fullhelp get windowscript("grinder help")end fullhelpon extrahelp if the optionkey is down and developing() then set the visible of cd fld helptext to not the visible of cd fld helptext set the locktext of cd fld helptext to not the visible of cd fld helptext if there is a cd fld id 27 then set the locktext of cd fld id 27 to not the visible of cd fld helptext end if else set the cantabort of this stack to true set the cursor to watch lock screen show cd fld helptext if there is a cd fld helptext2 then show cd fld helptext2 if there is a cd fld helptext3 then show cd fld helptext3 hide the target unlock screen with visual effect wipe down fast wait until the mouseclick lock screen hide cd fld helptext if there is a cd fld helptext2 then hide cd fld helptext2 if there is a cd fld helptext3 then hide cd fld helptext3 if there is a cd fld id 27 then set the locktext of cd fld id 27 to true show the target unlock screen with visual effect wipe up fast set the cantabort of this stack to false end ifend extrahelpon commandkeydown what if what is "L" and the shiftkey is down then loadafolder else if what is "M" and the shiftkey is down then mlm else if what is "T" then domenu "text style..." else if what is "R" then send "resetwheel" to this card else pass commandkeydownend commandkeydownon loadafolder answer folder "Select a folder to load into the Grinder:" if it is not empty then loaddocs itend loadafolderon mlm global multimsg ask password "Enter:" if it is not "4290235764" then exit mlm repeat with x = 1 to 10 ask "Line #"&x&return&"(* to end)" with line x of multimsg if it is "*" then exit repeat if it is empty then exit mlm put it & return after thingy end repeat if thingy is not empty then put thingy into multimsg do multimsg end ifend mlmon resetwheel if there is a cd btn "nextwheel" then put "None" into cd btn "nextwheel" set the icon of cd btn "nextwheel" to "wheelnotlinked" end if if there is a cd fld id 27 then set the locktext of cd fld id 27 to trueend resetwheel------------------------------------------------------------------------------TEXT WINDOW CODE------------------------------------------------on suspendwindow wdid,wdname global frontwindow if wdid & return & wdname = frontwindow then notextwindowend suspendwindowon notextwindow disable menuitem "save" of menu menuname("file") disable menuitem "save as..." of menu menuname("file") set the menumsg of menuitem "close" of menu menuname("file") to "domenu close stack" set the menumsg of menuitem "print" of menu menuname("file") to printer checkclosemenuend notextwindowon hasedit wdid,wdname global frontwindow enable menuitem "save" of menu menuname("file") enable menuitem "save as..." of menu menuname("file") set the menumsg of menuitem "close" of menu menuname("file") to "closetextfile" set the menumsg of menuitem "print" of menu menuname("file") to printTextFile enable menuitem "close" of menu menuname("file") enable menuitem "print" of menu menuname("file") enable menuitem "page setup..." of menu menuname("file") put wdid & return& wdname into frontwindowend hasediton printtextfile global frontwindow put textfield_text of window line 2 of frontWindow into thetext print thetextend printTextFileon noedit global frontwindow put empty into frontwindowend noediton closetextfile global frontwindow get closingwindow(line 1 of frontwindow,line 2 of frontwindow) if it is empty then --answered "don't save" set changed_hilite of window (line 2 of frontwindow) to false --to avoid tripping the closingwindow() function a second time close window (line 2 of frontwindow) else if it is not ":::Cancelled" then close window filename(it)end closetextfileon makenewtextfile get windowscript("Untitled")end makenewtextfileon savetext mode global frontwindow if there is a window line 2 of frontwindow then get savedfile(line 1 of frontwindow,line 2 of frontwindow,mode)end savetexton closewindow wdid,wdname --called by window when closed get closingwindow(wdid,wdname) if it is ":::Cancelled" then return blahblahend closewindowfunction closingwindow wdid,wdname set textfield_dirty of window wdname to false if changed_hilite of window wdname is true then set the cantabort of this stack to true answer "Save changes to" && wdname &"?" with "Cancel" or "Don't Save" or "Save" if it is "cancel" or it is empty then return ":::Cancelled" else if it is "Save" then get savedfile(wdid,wdname) if it is ":::Cancelled" then return ":::Cancelled" else put it into thefile else put empty into thefile set the cantabort of this stack to false return thefile end if notextwindowend closingwindowfunction savedfile wdid,wdname,mode put textfield_text of window wdname into thetext put filename_text of window wdname into thefile put i0_name of window wdname into shortfile -- if thefile is empty or mode is "SaveAs" then ask file "Save text file as:" with shortfile if it is empty then return ":::Cancelled" put it into thefile put "SaveAs" into mode end if open file thefile write thetext to file thefile close file thefile if mode is "saveAs" then put filename(thefile) into shortfile set the name of window wdname to shortfile put shortfile into wdname end if set textfield_dirty of window wdname to false set changed_hilite of window wdname to false return thefileend savedfileon opentextfile thefile set cursor to watch if thefile is empty then answer file "Open Text File:" of type TEXT if it is empty then exit opentextfile put it into thefile end if put filename(thefile) into shortfilename open file thefile read from file thefile until eof close file thefile put it into thetext if length(thetext) > 29000 then answer "Sorry. This document is too large to be opened in the HTML Grinder. You can grind this file, but not display it. Try opening it in your word processor." else get windowscript("Untitled",shortfilename,thefile,thetext)end opentextfile-------END OF TEXT WINDOW CODE----------------------------------------------------------------------------------------------------------------on helpnextwheel put the value of the target into theselect if theselect is "none" then get "Currently, no wheel is set to run after this wheel." else get "Currently, the" && theselect && "wheel is set to run after this wheel." helper "Press here to select a wheel you want to run immediately after this wheel finishes." && itend helpnextwheelon choosenextwheel global grindertools put the value of the target into thetext put grindertools & "-" &return& "None" into menuoptions if thetext is not in menuoptions then put "(" & thetext & return before line (the number of lines in menuoptions -1) of menuoptions put lineoffset(thetext,menuoptions) into theselect put lineoffset(the short name of this stack,menuoptions) into thedisable put "(" before line thedisable of menuoptions put lineoffset("Color Calculator",menuoptions) into thedisable put "(" before line thedisable of menuoptions -- get fullhpop(menuoptions,theselect,"窶「") if it is not empty then put item 1 of it into theitem put theitem into the target if theitem is "None" then set the icon of the target to "wheelnotlinked" else set the icon of the target to "wheellinked" end ifend choosenextwheel------------------------------------------------------------------------------GRINDING CODE---------------------------------------------------function findreplace thecontents,finder,changer,mode,caser global totalchanges if thecontents is "?" and finder is empty then return "findreplace(thecontents,finder,changer,firstonly,casesensitive)" if "firstonly" is in mode then put "false" into searchall else put "true" into searchall if "skipTags" is in mode then put tagFilter(theContents," ","text") into searchMe else put theContents into searchMe if caser is "casesensitive" then put "true" into casesens else put "false" into casesens -- put fullfind(searchMe,finder,false,searchall,casesens) into allchanges if allchanges is empty then return "ERROR: Text Not Found" if "findonly" is in mode then return allchanges put length(finder) -1 into chunklength put the number of lines in allchanges into thesechanges add thesechanges to totalchanges repeat with x=thesechanges down to 1 if there is a window "grinding..." then set cursor to busy if iconnum =1 then put 3 into iconnum else put 1 into iconnum set i3_name of window "grinding..." to "grinder"&iconnum end if put item 1 of line x of allchanges into startchar put startchar + chunklength into endchar put changer into char startchar to endchar of thecontents end repeat return thecontentsend findreplacefunction replacetaggedtext thecontents,thestart,theend,thetext global totalchanges if thecontents is "?" then return "replacetaggedtext(thecontents,thestart,theend,thetext)" get fullfind(thecontents,thestart,false) if it is empty then return "Error: Start Tag Not Found" put item 1 of it into startchar get fullfind(thecontents,theEnd,false) if it is empty then return "Error: End Tag Not Found" put item 1 of it + length(theEnd) -1 into endchar put thestart&return& thetext &return&theEnd into replacer put replacer into char startchar to endchar of thecontents add 1 to totalchanges return thecontentsend replacetaggedtextfunction append thecontents,thetext,where,whattext global totalchanges if thecontents is "?" then return "append(thecontents,thetext,where,whattext)" --first determine where to put text if where is "At Beginning of Document" then put "0" into charInsert else if where is "At End of Document" then put length(thecontents) into charInsert else if where is "At End of Document" then put length(thecontents) into charInsert else if where is "After Text:" or where is "before text:" then put fullfind(thecontents,whattext,false) into theplace if theplace is empty then return "Error: Text To Append To Not Found" if where is "After Text:" then put length(whattext) into chunklength else put "0" into chunklength put item 1 of theplace + chunklength -1 into charinsert end if -- --now stick the stuff in at the right place -- if charinsert is a number then add 1 to totalchanges put thetext after char charinsert of thecontents end if return thecontentsend appendfunction smartattach thecontents,thestart,theend,theText,appendWhere,appendPoint if thecontents is "?" then return "smartattach(thecontents,thestart,theend,theText,appendWhere,appendPoint)" put replacetaggedtext(thecontents,thestart,theend,theText) into newcontents if newcontents contains "error:" then put return & thestart & return & theText & return & theEnd &return into completeText put append(thecontents,completeText,appendWhere,appendPoint) into newcontents end if return newcontentsend smartattachfunction checktags thefile,thecontents,mode,thetags if mode is empty then put "all" into mode put empty into thingo repeat with x = 1 to the number of lines in thetags get line x of thetags put item 1 of it & " " into openTag put item 2 of it into paramName put item 3 of it into closeTag put item 4 of it into linkType put 1 into searchStart put empty into chunker repeat forever if word 4 of chunker is a number then put word 4 of chunker into searchStart put empty into thetext set cursor to busy -- --FIND THE OPEN TAG get smartfind(openTag,thecontents,searchStart) if it is "not found" then exit repeat put it && "of thecontents" into chunker -- --GET THE END OF THE OPEN TAG get smartfind(">",thecontents,word 4 of chunker) if it is "not found" then --no closing > put linkType & ",ERROR: closing angle bracket missing" into thestatus put "ERROR: closing angle bracket missing" into theText put thestatus & "," & thefile &",," & thetext &","& word 2 of chunker & "," & word 4 of chunker &return after thingo next repeat end if put word 4 of it into word 4 of chunker put the value of chunker into completeOpenTag -- --MAKE SURE OPEN TAG IS VALID if char 2 to 100000 of completeOpenTag contains "<" then --contains a <, so we got two tags, one wasn't closed properly put linkType & ",ERROR: closing angle bracket missing" into thestatus put "ERROR: closing angle bracket missing" into theText put thestatus & "," & thefile &",," & thetext &","& word 2 of chunker & "," & word 4 of chunker &return after thingo next repeat end if -- --NOW FIND THE CLOSE TAG IF APPROPRIATE if closeTag is not empty then get smartfind(closeTag,thecontents,word 4 of chunker) if it is "not found" then --no closing tag found put chunker into checkchunk add 2 to word 2 of checkchunk put offset(">",the value of checkchunk) into nexttag if nexttag=0 then put offset("<",the value of checkchunk) into nexttag if nexttag =0 then put length(thefile) into nexttag put word 2 of chunker + nexttag into word 4 of chunker put word 4 of chunker into searchStart put linkType & ",ERROR: no" && closetag && "tag found" into thestatus put "ERROR: no" && closetag && "tag found" into thetext put thestatus & "," & thefile &",," & thetext &","& word 2 of chunker & "," & word 4 of chunker &return after thingo next repeat end if end if -- -- --We've got the entire tag. From open tag to close tag (if existing) --Now we make sure it's ok internally -- put word 4 of chunker into searchStart -- get extractreference(completeOpenTag,paramName) if it is empty then next repeat put line 1 of it into thetext put line 2 of it into refchunks if "#" is in thetext then next repeat --skip the scrolling links for now if "ERROR: " is in thetext or "OUTLINK: " is in thetext then put thetext into thestatus put linkType &"," & thestatus & "," & thefile &",," & thetext &","& word 2 of chunker & "," & word 4 of chunker &"," & refchunks &return after thingo next repeat end if put absolutepath(thefile,thetext) into linkedfile if there is a file linkedfile then put linktype & ",OK" into thestatus else put linkType & ",ERROR: File not found" into thestatus end if if mode is "all" or mode is "good" then put thestatus & "," & thefile &"," & linkedfile & "," & thetext &","& word 2 of chunker & "," & word 4 of chunker &"," & refchunks &return after thingo -- end repeat end repeat return thingoend checktags-----------------------------------------------------------------------------------COMMONLY USED CODE-----------------------------------------function smartfind thetext,thecontainer,startchar if startchar is not a number then put "1" into startchar put length(thecontainer) into endchar get fullfind(char startchar to endchar of thecontainer,thetext,false) if it is empty then return "Not Found" else put (item 1 of it) + startchar -1 into founder return "char" && founder && "to" && (founder + length(thetext) -1) end ifend smartfindfunction extractTitle thecontents put fullfind(thecontents,"<title>",false) into starter if starter is empty then return "" put item 1 of starter + length("<title>") into starter -- put fullfind(thecontents,"</title>",false) into ender if ender is empty then return "" put item 1 of ender -1 into ender -- put char starter to ender of thecontents into theTitle put stripreturns(theTitle) into theTitle return theTitleend extractTitlefunction extractTaggedText thecontents,thetag if char 1 of thetag is not "<" or last char of thetag is not ">" then put "<" & thetag & ">" into thetag put thetag into theEndTag put "/" after char 1 of theEndTag put fullfind(thecontents,thetag,false) into starter if starter is empty then return "ERROR: Tag not found" put item 1 of starter + length(thetag) into starter -- put fullfind(thecontents,theEndTag,false) into ender if ender is empty then return "ERROR: Tag not found" put item 1 of ender -1 into ender -- put char starter to ender of thecontents into thetext return starter &","& ender &return& thetextend extractTaggedTextfunction stripreturns input put empty into output repeat with x= 1 to the number of lines in input put line x of input after output end repeat return outputend stripreturnsfunction colonstoSlashes thefile repeat with x = 1 to length(thefile) if char x of thefile is ":" then put "/" into char x of thefile end repeat return thefileend colonstoslashesfunction relativepath fromfile,tofile set the itemdelimiter to ":" repeat with x = 1 to the number of items in tofile if item x of tofile <> item x of fromfile then exit repeat end repeat put x-1 into commonfolders delete item 1 to commonfolders of tofile delete item 1 to commonfolders of fromfile repeat (the number of items in fromfile -1) put "../" before tofile end repeat set the itemdelimiter to "," return colonstoslashes(tofile)end relativepathfunction absolutepath fromfile,tofile set the itemdelimiter to ":" delete last item of fromfile set the itemdelimiter to "/" repeat with x = 1 to the number of items in tofile if item x of tofile = ".." then set the itemdelimiter to ":" delete last item of fromfile set the itemdelimiter to "/" else put ":" & item x of tofile after fromfile end if end repeat set the itemdelimiter to "," return fromfileend absolutepathfunction extractReference theLink,RefParam if RefParam is empty then put "HREF" into refParam get smartfind((refParam & "="),theLink) if it is "not found" then get smartfind((refParam && "="),theLink) if it is "not found" then return "ERROR: Couldn't extract" && refParam &". Nonstandard format." end if end if put word 2 of it into startofparam put word 4 of it into endofparam put char startofparam to endofparam of thelink into theparam -- --Get the start of the thing put word 4 of it +1 into startofthing repeat until char startofthing of thelink is not " " add 1 to startofthing end repeat put char startofthing to (length(theLink)-1) of theLink into thething -- --Find the end, marked by a quote or by a space if char 1 of thething is quote then put offset(quote,char 2 to 10000 of thething) into endofthing if endofthing is "1" then return "ERROR: missing close quote" end if else put offset(" ",thething) -1 into endofthing if endofthing is "-1" then put length(thething) -1 into endofthing end if add startofthing to endofthing -- --Strip out final spaces if necessary repeat until char endofthing of thelink is not " " subtract 1 from endofthing end repeat -- put char startofthing to endofthing of thelink into newthing -- --check for no open quote if char 1 of newthing is not quote then if last char of newthing is quote then return "ERROR: missing open quote" else if newthing contains quote then return "ERROR: misplaced quote mark" end if -- --Strip out quotes if appropriate if char 1 of newthing is quote then if last char of newthing is quote then add 1 to startofthing subtract 1 from endofthing put char startofthing to endofthing of thelink into newthing else return "ERROR: missing close quote" end if end if -- put newthing into thesource if refparam is in "href,img" then if ":/" is in thesource or "mailto:" is in thesource then if "mailto:" is in thesource then put "mailto" into theprotocol else set the itemdelimiter to "/" put item 1 of thesource into theprotocol if last char of theprotocol is ":" then delete last char of theprotocol set the itemdelimiter to "," end if return "OUTLINK:" && theprotocol && "reference" end if if char 1 of thesource is "/" then return "ERROR: absolute (non-relative) reference" end if -- return thesource &return & startofparam &","&endofparam &","& startofthing &","& endofthingend extractReferencefunction trimReference theSource repeat until char 1 of theSource is not " " delete char 1 of theSource end repeat if char 1 of theSource is quote then delete char 1 of theSource put "true" into requirequote else put "false" into requirequote get offset (" ",theSource) if it is not 0 then put char 1 to it of theSource into theSource get offset (quote,theSource) if it is 0 then if requirequote is true then return "ERROR: No close quote" end if else if requirequote is "false" then return "ERROR: No open quote" else put char 1 to (it-1) of theSource into theSource end if return theSourceend trimReferencefunction midelipse theinput,thelimit if thelimit is empty then put 34 into thelimit put length(theinput) into howlong if howlong <= thelimit then return theinput put trunc(thelimit/3) -1 into thehalfwaymark return char 1 to (thehalfwaymark-2) of theinput & "窶ヲ" & char (howlong - (thelimit-thehalfwaymark)) to howlong of theinputend midelipsefunction lineoffset thetext,thecontainer return item 2 of fullfind(thecontainer,thetext,true)end lineoffset-----------function backupfile thefile,thecontents if there is no file thefile then return "ERROR: No such file to backup." if thecontents is empty then open file thefile read from file thefile until eof close file thefile put it into thecontents end if put filename(thefile) into thefilename put folder(thefile) into thefolder put "0" into thesuffix repeat forever add 1 to thesuffix put thefilename into newfilename if length(newfilename) >26 then put char 1 to 25 of newfilename & "窶ヲ" into newfilename put newfilename && "BU" into newfilename if thesuffix >1 then put thesuffix after newfilename if there is no file (thefolder & newfilename) then exit repeat else next repeat end repeat get thefolder & newfilename open file it if the result is not empty then return "Error: couldn't write backup file." write thecontents to file it close file it return itend backupfileon goprefs global chimer,clearfield,suffixes,grindonlysuffixed if grindonlysuffixed is empty then put false into grindonlysuffixed put clearfield &return& chimer &return& grindonlysuffixed &return& suffixes into oldprefs get windowscript("Preferences",clearfield,chimer,(not grindonlysuffixed),grindonlysuffixed,(not grindonlysuffixed),suffixes) if it is "cancel" then exit goprefs put line 2 of it into clearfield put line 3 of it into chimer put line 4 of it into grindonlysuffixed put line 5 to 10000 of it into suffixes put clearfield &return& chimer &return& grindonlysuffixed &return& suffixes into newprefs if newprefs <> oldprefs then lockall card go homie() in new window hide card window put newprefs into bg fld theprefs unlockall card end ifend goprefson loadeddocs global allfiles if length(allfiles) >30000 then answer "There are too many loaded documents to display. You will still be able to grind these documents, but they will not be loaded after you quit the Grinder." exit loadeddocs end if get windowscript("loaded documents",allfiles) if it is not empty then if line 2 to 300000 of it is not allfiles then lockall card go homie() in new window put line 2 to 30000 of it into allfiles put allfiles into bg fld docs unlockall card end if end ifend loadeddocson nonhtmlConverterend nonhtmlConverteron converterend converteron replaceFile thefile,thecontents open file thefile write thecontents to file thefile close file thefileend replaceFileon helper what FullBalloons "ShowDirect",whatend helperon printer domenu "print card"end printeron closecard if there is a cd fld helptext then hide cd fld helptext show cd btn "more..." end if pass closecardend closecardon enterkey if the enabled of cd btn 1 = "true" then set the hilite of cd btn 1 to true wait 5 set the hilite of cd btn 1 to false send mouseup to cd btn 1 end ifend enterkeyon enterinfield enterkeyend enterinfieldon domenu what,where if where is "Tools " then global toolfolder set cursor to watch get toolfolder&what go stack it in new window else if what is "close" then if there is a window "Grinder Help" then beep else pass domenu else pass domenuend domenufunction validateOld thenumber put return& possibleserials("Grinder",the short date) into serials if return&thenumber&return is in serials then return "" else return "ERROR"end validateoldfunction possibledates datso if datso is empty then put the date into thisdate else put datso into thisdate put empty into alldates repeat 14 times convert thisdate to dateitems put thisdate&return after alldates subtract 1 from item 3 of thisdate convert thisdate to long date end repeat return alldatesend possibledatesfunction seeder input put 0 into totalSeed repeat with x =1 to length(input) if char x of input = " " then next repeat add ((chartonum(char x of input)^3)/2) to totalseed end repeat return (totalseed^5)end seederon quit global tempfile set cursor to watch set lockmessages to true if developing() then keepscript if there is a stack tempfile then get deletefile(tempfile) pass quitend quitfunction RegFile input put systemfolder() into thesysfolder put thesysfolder &"Preferences:" into theprefFolder if there is no folder theprefFolder then put thesysfolder into theprefFolder put theprefFolder & "HTML Grinder Prefs" into thepref if input = "" then open file thePref read from file thePref until eof close file thePref return it else open file thePref write input to file thePref close file thePref get ChangeFileType(thepref,pref) setfileflag thepref,invisible,true return "" end ifend regFileon closefield put the value of the target into the target pass closefieldend closefield</text>
</content>
<content>
<layer>card</layer>
<id>13</id>
<text>G46-2785-311</text>
</content>
<content>
<layer>card</layer>
<id>20</id>
<text>on checkversion requiredversion global grinderversion if not developing() then set the cantabort of this stack to true put grinderversion into verso if verso < requiredversion then answer "This wheel requires version" && requiredversion && "or later of the HTML Grinder" &&ツャ "(you have version" && verso & ")." &&ツャ "Download the complete bundle from" &return&ツャ " http://www.matterform.com/" with "Cancel" set the cantabort of this stack to false if the number of lines in the stacks >1 then send "domenu close stack" to hypercard else go homie() hide card window end if exit to hypercard end if end ifend checkversion</text>